//
//  VCOfContent.m
//  212--Homework  QQy音乐  阿里星球
//
//  Created by 冀永金 on 16/8/15.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "VCOfContent.h"
#import "UIImageView+WebCache.h"
#import "ThirdModel.h"
#import "ForthModel.h"
#import "JYYNetWorkParser.h"

@interface VCOfContent ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UIImageView *image;
@property (nonatomic, strong) UITableView *tabelView;
@property (nonatomic, strong) NSDictionary *dic;
@property (nonatomic, strong) UIImageView *smallImage;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *dataLabel;
@end

@implementation VCOfContent

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBar.translucent = YES;
    [self config];
    
    [self handleData];
    
        // Do any additional setup after loading the view.
}
- (void)handleData {
    [JYYNetWorkParser GETWithURL:[NSString stringWithFormat:@"http://api.dongting.com/song/album/%@",self.model1.value] par:nil success:^(id responseObject) {
        self.dic = responseObject[@"data"];
        self.image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 300)];
        [self.tabelView addSubview:_image];
        [self.image sd_setImageWithURL:[NSURL URLWithString:_dic[@"picUrl"]]];
        self.smallImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 210, 60, 60)];
        [self.image addSubview:_smallImage];
        _smallImage.layer.cornerRadius = 30;
        _smallImage.clipsToBounds = YES;
        [self.smallImage sd_setImageWithURL:[NSURL URLWithString:_dic[@"singerPicUrl"]]];
        self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 210, 80, 35)];
        [self.image addSubview:_nameLabel];
        self.nameLabel.text = _dic[@"singerName"];
        self.nameLabel.textColor = [UIColor whiteColor];
        self.dataLabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 245, 150, 30)];
        [self.image addSubview:_dataLabel];
        self.dataLabel.text = [NSString stringWithFormat:@"发行日期%@",_dic[@"publishDate"]];
        self.dataLabel.textColor = [UIColor whiteColor];
        self.dataLabel.font = [UIFont systemFontOfSize:15];
            } filed:^(NSError *error) {
        
    }];
}
- (void)config {
    self.tabelView = [[UITableView alloc]initWithFrame:CGRectMake(0,0, self.view.frame.size.width, self.view.bounds.size.height) style:UITableViewStylePlain];
    [self.view addSubview:_tabelView];
    //self.tabelView.contentInset = UIEdgeInsetsMake(300, 0, 0, 0);

    self.tabelView.delegate = self;
    self.tabelView.dataSource = self;
    [self.tabelView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"pool"];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"pool" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor redColor];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 80;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return @" ";
}
//- (void)scrollViewDidScroll:(UIScrollView *)scrollView
//{
//    CGFloat yOffset = scrollView.contentOffset.y;
//    CGFloat xOffset = (yOffset + 300) / 2;
//    
//    if (yOffset < - 300) {
//        
//        CGRect f = self.image.frame;
//        f.origin.y = yOffset;
//        f.size.height = - yOffset;
//        f.origin.x = xOffset;
//        f.size.width = self.view.frame.size.width + fabs(xOffset) * 2;
//        self.image.frame = f;
//    }
//    
//    self.navigationController.navigationBar.alpha = (yOffset + 300) / (300 + 64);
//    self.navigationController.navigationBar.barTintColor = [UIColor cyanColor];
//    
//}


//- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
//    
//}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 80;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
